package net.lanelife.casino.caipiao.job;

import net.lanelife.casino.caipiao.entity.Job;
import net.lanelife.casino.caipiao.repository.api.IJobRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Lazy(false)
@Component
public class JobDispatcher {
	
	@Autowired
	private IJobRepository jobRepository;
	
	@Transactional(rollbackFor = Exception.class)
	public void dispatch(Job job, JobInfo info) throws Exception {
		job.writeInfo(info);
		jobRepository.save(job); // 任务入库
	}

}
